package com.csun.cmny.provider.security;

import com.csun.cmny.security.core.authorize.AuthorizeConfigProvider;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.stereotype.Component;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2018-11-22 13:58
 * @Description:
 */
@Order
@Component
public class MyPermissionAuthorizeConfigProvider implements AuthorizeConfigProvider {

    /**
     * Config boolean.
     *
     * @param config the config
     *
     * @return the boolean
     */
    @Override
    public boolean config(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry config) {
        config
                .anyRequest()
                .access("@permissionService.hasPermission(authentication,request)");
        return true;
    }
}
